import config from 'config';
import httpFetch from 'share/httpFetch';
import errorMessage from 'share/errorMessage';
import axios from 'axios';
import configureStore from 'stores';

export default {
  //获取用户类型
  getTableData(page, params) {
    return new Promise((resolve, reject) => {
      httpFetch.get(config.baseUrl + `/api/customer/type/list?page=${page}&size=10`, params)
        .then((res) => {
          resolve(res)
        })
        .catch((err) => {
          errorMessage(err.response);
          reject(err);
        })
    })
  },

  //新增客户类型
  addCustomerType(params) {
    return new Promise((resolve, reject) => {
      httpFetch.post(config.baseUrl + `/api/customer/type/create`, params)
        .then((res) => {
          resolve(res)
        })
        .catch((err) => {
          errorMessage(err.response);
          reject(err);
        })
    })
  },

  //编辑客户类型
  editCustomerType(params) {
    return new Promise((resolve, reject) => {
      httpFetch.put(config.baseUrl + `/api/customer/type/update`, params)
        .then((res) => {
          resolve(res)
        })
        .catch((err) => {
          errorMessage(err.response);
          reject(err);
        })
    })
  },
}
